package org.javaforever.gatescore.reports;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.javaforever.gatescore.core.FrontDomain;
import org.javaforever.gatescore.core.FrontField;
import org.javaforever.gatescore.core.Statement;
import org.javaforever.gatescore.core.StatementList;
import org.javaforever.gatescore.core.Writeable;
import org.javaforever.gatescore.core.WriteableUtil;
import org.javaforever.gatescore.reports.verb.CompareSetup;
import org.javaforever.gatescore.reports.verb.ListActiveCompareOption;
import org.javaforever.gatescore.reports.verb.ListActiveCompareSumOption;
import org.javaforever.gatescore.reports.verb.ListActiveOption;
import org.javaforever.gatescore.reports.verb.ListActiveSumOption;
import org.javaforever.gatescore.reports.verb.Setup;
import org.javaforever.gatescore.widgets.Widget;

public class EchartsCompareDiagram extends Widget{
	protected FrontDomain planDomain;
	protected FrontDomain actionDomain;
	protected List<FrontField> planxAxisFields = new ArrayList<>();
	protected FrontField planyName;
	protected List<FrontField> actionxAxisFields = new ArrayList<>();
	protected FrontField actionyName;
	protected String detailPrefix = "";
	protected Set<FrontDomain> tranlateDomains = new TreeSet<>();
	protected Set<FrontDomain> parentTranlateDomains = new TreeSet<>();
	protected ListActiveCompareOption listOption;
	protected ListActiveCompareSumOption listSumOption;
	protected CompareSetup setup;
	
	public EchartsCompareDiagram(FrontDomain planDomain, List<FrontField> planxAxisFields, FrontField planyName, FrontDomain actionDomain,List<FrontField> actionxAxisFields, FrontField actionyName) {
		super();
		this.planDomain = planDomain;
		this.actionDomain = actionDomain;
		this.planxAxisFields = planxAxisFields;
		this.planyName = planyName;
		this.actionxAxisFields = actionxAxisFields;
		this.actionyName = actionyName;
		
		this.listOption = new ListActiveCompareOption(planDomain,planxAxisFields,planyName,actionDomain,actionxAxisFields,actionyName);
		this.listSumOption = new ListActiveCompareSumOption(planDomain,planxAxisFields,planyName,actionDomain,actionxAxisFields,actionyName);
		this.setup = new CompareSetup(planDomain,actionDomain,this.listOption,this.listSumOption);
	}
	
	@Override
	public StatementList generateWidgetStatements() {
		List<Writeable> sList = new ArrayList<>();
		sList.add(new Statement(2000L,0,"<el-select v-model=\"chartType\" placeholder=\"请选择\" @change=\"setup\">"));
		sList.add(new Statement(3000L,1,"<el-option"));
		sList.add(new Statement(4000L,2,"v-for=\"item in chartTypes\""));
		sList.add(new Statement(5000L,2,":key=\"item.value\""));
		sList.add(new Statement(6000L,2,":label=\"item.label\""));
		sList.add(new Statement(7000L,2,":value=\"item.value\"/>"));
		sList.add(new Statement(9000L,0,"</el-select>"));
		sList.add(new Statement(11000L,0,"<el-select v-model=\"dataType\" placeholder=\"请选择\" @change=\"setup\">"));
		sList.add(new Statement(12000L,1,"<el-option"));
		sList.add(new Statement(13000L,2,"v-for=\"item in dataTypes\""));
		sList.add(new Statement(14000L,2,":key=\"item.value\""));
		sList.add(new Statement(15000L,2,":label=\"item.label\""));
		sList.add(new Statement(16000L,2,":value=\"item.value\"/>"));
		sList.add(new Statement(18000L,0,"</el-select>"));
		sList.add(new Statement(20000L,0,"<div id=\"main\" ref=\"chart\" :style=\"{width: '1000px', height: '600px'}\"/>"));

		StatementList rsl = WriteableUtil.merge(sList);
		rsl.setSerial(this.serial);
		return rsl;
	}

	@Override
	public StatementList generateWidgetScriptStatements() throws Exception {
		List<Writeable> sList = new ArrayList<Writeable>();

		return WriteableUtil.merge(sList);
	}

	@Override
	public boolean parse() {
		// TODO Auto-generated method stub
		return false;
	}

	public String getDetailPrefix() {
		return detailPrefix;
	}

	public void setDetailPrefix(String detailPrefix) {
		this.detailPrefix = detailPrefix;
	}

	public FrontDomain getPlanDomain() {
		return planDomain;
	}

	public void setPlanDomain(FrontDomain planDomain) {
		this.planDomain = planDomain;
	}

	public FrontDomain getActionDomain() {
		return actionDomain;
	}

	public void setActionDomain(FrontDomain actionDomain) {
		this.actionDomain = actionDomain;
	}

	public List<FrontField> getPlanxAxisFields() {
		return planxAxisFields;
	}

	public void setPlanxAxisFields(List<FrontField> planxAxisFields) {
		this.planxAxisFields = planxAxisFields;
	}

	public FrontField getPlanyName() {
		return planyName;
	}

	public void setPlanyName(FrontField planyName) {
		this.planyName = planyName;
	}

	public List<FrontField> getActionxAxisFields() {
		return actionxAxisFields;
	}

	public void setActionxAxisFields(List<FrontField> actionxAxisFields) {
		this.actionxAxisFields = actionxAxisFields;
	}

	public FrontField getActionyName() {
		return actionyName;
	}

	public void setActionyName(FrontField actionyName) {
		this.actionyName = actionyName;
	}

	public Set<FrontDomain> getTranlateDomains() {
		return tranlateDomains;
	}

	public void setTranlateDomains(Set<FrontDomain> tranlateDomains) {
		this.tranlateDomains = tranlateDomains;
	}

	public Set<FrontDomain> getParentTranlateDomains() {
		return parentTranlateDomains;
	}

	public void setParentTranlateDomains(Set<FrontDomain> parentTranlateDomains) {
		this.parentTranlateDomains = parentTranlateDomains;
	}

	public ListActiveCompareOption getListOption() {
		return listOption;
	}

	public void setListOption(ListActiveCompareOption listOption) {
		this.listOption = listOption;
	}

	public ListActiveCompareSumOption getListSumOption() {
		return listSumOption;
	}

	public void setListSumOption(ListActiveCompareSumOption listSumOption) {
		this.listSumOption = listSumOption;
	}

	public CompareSetup getSetup() {
		return setup;
	}

	public void setSetup(CompareSetup setup) {
		this.setup = setup;
	}
}
